package ae_server;



import net.TCP_Message;
import net.TCP_MultiThreadServer;

public class aeTempClientHandler extends Thread
{
	private static boolean isServerAlive;
	private int i=0;
	private TCP_Message msg;
	public synchronized void start()
	{
		isServerAlive=true;
		super.start();
	}
	public void run()
	{
		while(isServerAlive)
		{
			for(i=0; i<TCP_MultiThreadServer.tempClients.size(); ++i)
			{
				msg=TCP_MultiThreadServer.tempClients.get(i).getMessage();
				if (msg==null)
					continue;
				else if(msg.cmd.equals("NET_ER"))
				{
					System.out.println("Temporary client disconnected. Reason: "+msg.data);
					TCP_MultiThreadServer.tempClients.remove(i);
					--i;
				}
				else
					System.out.println("Unknown command: "+msg.cmd);
			}
		}
	}
	public void StopHandling()
	{
		isServerAlive=false;		
	}
}
